package com.baizhi.ems_thymeleaf.service.impl;

import com.baizhi.ems_thymeleaf.mapper.EmployeeMapper;
import com.baizhi.ems_thymeleaf.pojo.Employee;
import com.baizhi.ems_thymeleaf.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class EmpServiceImpl implements EmpService {

    @Autowired
    EmployeeMapper employeeMapper;
    @Override
    public List<Employee> queryAll() {
        List<Employee> list =  employeeMapper.queryAll();
        return list;
    }

    @Override
    public void save(Employee employee) {
        employeeMapper.insert(employee);
    }

    @Override
    public Employee selectById(Long id) {
        return  employeeMapper.selectByPrimaryKey(id);
    }

    @Override
    public void update(Employee employee) {
        employeeMapper.updateByPrimaryKey(employee);
    }

    @Override
    public void delete(Long id) {
        employeeMapper.deleteByPrimaryKey(id);
    }
}
